
<script type="text/javascript" >

	var contentPath = "/MedicalSystem/ccfapp/pojo/";
	var _gt_grid_init_params = '$parameters';
	var _gt_grid_data_provider = "$provider";
	
	//------------------------------------------
	// 缺省的列值设置函数 
	//------------------------------------------
	function columnSet(value ,record, columnObj, grid, colNo, rowNo) { 	
		if (value == 'null' || value == '') return '';
		else return value;  
	}
	
	function onRow_Selected(value) {}
	
	var dsConfigDim = [];
	var colsConfigDim = [];
	var gridConfigDim = [];
	
	dsConfigDim[GTGridCountInPage] = {
		fields :[
					#foreach( $head in $header )	
						{name : '$head.name', fieldType : '$head.fieldType'},
					#end		
				],
		recordType : 'object'
	};
	
	#set($i = 1)
	#set($hasCheckedColumn = false)
	#set($headCaptions = "")
	#set($headFieldNames = "")
	#set($headNeedExport = "")
	#set($headFieldOptions = "")
	
	colsConfigDim[GTGridCountInPage] = [
		#foreach( $head in $header )
			#if ($head.isChecked == "true")
			    #set($hasCheckedColumn = true)
			#end
			#set($headAlign = 'center')
			#if ($head.isChecked == 'true')
				#set($headAlign = 'left')
			#end
			#if ($head.render != "")
				{ id : '$head.name' , header : "$head.header " , emptyText:"", width : "$head.width", isCheckColumn : $head.isChecked ,headAlign:'$headAlign',  align :'$head.align',  renderer : $head.render}
			#else
				{ id : '$head.name' , header : "$head.header " , emptyText:"", width : "$head.width", isCheckColumn : $head.isChecked  ,headAlign:'$headAlign',  align :'$head.align' }
			#end		
			#set($i = $i+1)
			#set($headCaptions = $headCaptions + $head.header + ",")
			#set($headFieldNames = $headFieldNames + $head.name + ",")
			#set($headNeedExport = $headNeedExport + $head.needExport + ",")
			#set($headFieldOptions = $headFieldOptions + $head.options + "|")
			#if ($i <= $header.size()),
			#end
			#end		
	];

	gridConfigDim[GTGridCountInPage] = {
	
		id : "$gridId",
		
		//数据源的属性描述
		dataset : dsConfigDim[GTGridCountInPage] ,
	
		//列头的数据描述
		columns : colsConfigDim[GTGridCountInPage] ,
	
		//表格控件显示的对应的div的id
		container : 'container$gridId', 
		
		//toolbarPosition显示的位置，如果要显示工具栏，则显示在最底下，如果不显示，则置为null
		#if ($hasToolbar == "true")
			toolbarPosition : 'bottom',
		#else
			toolbarPosition : null,
		#end	
		
		//是否支持过滤条件
		#if ($filterSupport == "true")
			toolbarContent : 'nav | goto | pagesize | reload | filter |state' ,
		#else
			toolbarContent : 'nav | goto | pagesize | reload | state' ,
		#end	
		
	
		#if ($hasCheckedColumn == "true")
			selectRowByCheck: true,
		#else
			selectRowByCheck: false,
		#end	
		
		//是否自动加载数据，默认是true
		autoLoad: $autoLoad,
		
		//是否显示行的索引
		showIndexColumn: ${showIndexColumn},
	
		onClickCell: $onCellClicked,
		#if ($onCellDblClicked != "")
			onDblClickCell: $onCellDblClicked,
		#end	
		loadResponseHandler : myResponseHandler, 
		pageSize : $rowPerPage ,	
		pageSizeList : [5,10,15,20,25,50,100],	
		
		//如果数据是远程异步加载,则需要提供一个url地址	
		loadURL: contentPath + "$provider",	
		remotePaging: true,
		
		//是否渲染行	
		#if ($rowRender != "")
			renderRow : $rowRender,
		#end	
		
		//默认的参数
		parameters: {$parameters}
	};
	
	</script> 

	<!-- grid的容器. -->
	<div id="container$gridId" style="$css;overflow:auto"></div>
	<script>
		if (document.getElementById("container$gridId").style.width.indexOf("%")>0 && document.body.clientWidth>0) {
		
			//如果grid容器的div的宽度是用百分比指定的，则获得body的宽度进行转换成px类型
			var width = document.getElementById("container$gridId").style.width;
			document.getElementById("container$gridId").style.width = document.body.clientWidth * (width.substring(0, width.length-1) / 100) - 2;
		}
	</script>


	<script>
	
	
	var $gridId = new Sigma.Grid( gridConfigDim[GTGridCountInPage] );
	$(document).ready(function(){
		var pNode = document.getElementById("container${gridId}").parentNode;
		if (pNode) {
			if (Sigma.isFF) {
				${gridId}.width = pNode.clientWidth - 2;
				${gridId}.height = pNode.clientHeight;
			}
			if (Sigma.isChrome) {
				${gridId}.width = pNode.clientWidth - 2;
				${gridId}.height = pNode.clientHeight - 18;
			}  		
		}
		
		//初始化表格的时候渲染行
		$gridId. render();
		
		#if ($hasToolbar == "false")	
			var temp = document.getElementById("$gridId" + "_bodyDiv");
			if (temp) temp.style.height = parseInt(temp.style.height) + 24;
		#end		
	})  

	

	/**
	 * 自动选中Render方法设置的checked状态的行 
	 * render 方法里面还未初始化表格，所以放在 grid 的 complete 事件处理
	 */

	$gridId. onComplete = function(grid) { 		
		var checklist = GRID_SELECTED_ROWIDX.split(",");
		for (var i=0; i<checklist.length; i++)
			grid.selectRowByIdx(checklist[i]); 
		GRID_SELECTED_ROWIDX = "";
		// 必须在这里设置自定义的行样式      
		for (p in this.rowStyleSettings) {		
			grid.ao9(p).className = this.rowStyleSettings[p];
		}
	}

	/**
	* 用于获取当前grid的查询参数
	* By ZhouHuan, 2010-3-2
	*/
	function getGridParameters() {
		var params = $gridId. parameters;
		var str = [];
		for(var k in params) {
			// 跳过params中没有被赋值
			if((params[k]+"").indexOf("${") == 0) continue; 
			str.push( k +"="+ params[k]);
		}
		return str.join("$");
	}
		
</script>
